//
// GPSMapEdit
// (c) Konstantin Galichsky (kg@geopainting.com), 2007
//
// WinInet API helpers.
//

# include "StdAfx.h"
# include "Inet.h"

/*# include "Ras.h"
# pragma comment (lib, "Rasapi32.lib")

bool AreThereActiveRasConnections () {
	RASCONN rc;
	::memset (& rc, 0, sizeof (rc));
	rc.dwSize = sizeof (RASCONN);

	DWORD dwBytes = sizeof (RASCONN);
	DWORD dwCount = 0;
	::RasEnumConnections (& rc, & dwBytes, & dwCount);

	return dwCount > 0;
}*/

bool IsInetOffline (const char * _strURL) {
//	if (! AreThereActiveRasConnections ())
//		return false;

//	if (::InternetCheckConnection (NULL, FLAG_ICC_FORCE_CONNECTION, 0) == FALSE)
//		return true;

	DWORD dwFlags = 0;
	const BOOL bResult = ::InternetGetConnectedState (& dwFlags, 0);
	// NOTE: ::InternetCheckConnection() doesn't work correctly with connections through proxy.
	if (dwFlags & INTERNET_CONNECTION_PROXY)
		return false;

	if (::InternetCheckConnection (_strURL, 0, 0) == FALSE)
		return true;

	return false;
}
